package com.book.controller;

import com.book.adapter.Login3rdAdapter;
import com.book.pojo.UserInfo;
import com.book.service.UserInfoService;
import com.book.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
@RequiredArgsConstructor
public class UserController {


	private final Login3rdAdapter login3rdAdapter;


	@PostMapping("login")
	public String login(@RequestBody UserInfo userInfo){
		return login3rdAdapter.userInfoService.login(userInfo.getUsername(),userInfo.getUserPassword());
	}


	@PostMapping("register")
	public String register(@RequestBody UserInfo userInfo){
		return login3rdAdapter.userInfoService.register(userInfo);
	}

	@GetMapping("gitee")
	public String gitee(String code,String state){
		return login3rdAdapter.loginByGitee(code,state);
	}
}
